#include<bits/stdc++.h>
#define int long long 

using namespace std;

signed main() {
	string s1, s2;
	cin >> s1 >> s2;
	if(s1 == s2) {
		cout << 0 << endl;
		return 0;
	}
	int t = min(s1.size(), s2.size());
	for(int i = 0; i < t; i ++ ) {
		if(s1[i] != s2[i]) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << t + 1 << endl;
	return 0;
}

